<template>
  <div>
    <p>商品管理</p>
    <el-pagination
      @current-change="handleCurrentChange"
      :current-page.sync="currentPage1"
      :page-size="size"
      layout="total, prev, pager, next"
      :total="total">
    </el-pagination>
  </div>
</template>
<script>
  import {goodscount, goodslist} from '../request/index'
export default {
  data() {
    return {
      // 数据总条数
      total: 0,
      // 每页显示几条
      size: 5,
      // 当前页码
      currentPage1: 1
    }
  },
  created() {
    // 获取数据的总条数，用于判断分页
    this.getTotalConut();
    // 获取页面的数据
    this.getData()
  },
  methods: {
    async getTotalConut() {
      let res = await goodscount();
      this.total = res.list[0].total;
    },
    async getData() {
      let res = await goodslist({
        size: this.size,
        page: this.currentPage1
      });
      console.log(res);
    },
    // 当前页修改，就是指点击分页的按钮，需要获取对应页码的数据
    handleCurrentChange() {
      this.getData()
    }
  },
}
</script>
<style lang="">
  
</style>